package com.example.administrator.nurse.widget;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.administrator.nurse.R;

/**
 *  Created by 林冠宏 on 2016/4/23.
 *  输入项工具类
 *
 */

/**
 *  <TextView
     android:id="@+id/text"
     android:text="测量时间:"
     android:textSize="14sp"
     android:layout_weight="1"
     android:layout_width="0dp"
     android:layout_height="wrap_content" />
     <com.example.administrator.nurse.widget.LoginInputEdit
     android:id="@+id/input"
     android:textSize="14sp"
     android:background="@null"
     android:layout_weight="4"
     android:layout_width="0dp"
     android:layout_height="wrap_content"
 />
 *
 * */

public class ItemInput {

    private Context context;
    private View view;

    public ItemInput(Context context){
        this.context = context;
        this.view = LayoutInflater.from(context).inflate(R.layout.input_item,null,false);
    }

    public ItemInput(Context context,View parent){
        this.context = context;
        this.view = LayoutInflater.from(context).inflate(R.layout.input_item, (ViewGroup) parent,false);
    }

    public View getView(){
        return view;
    }

    private String title = null;
    private String data = null;//hhc
    public ItemInput withTitle(String title){
        this.title = title;
        return this;
    }

    //hhc 数据显示
    public ItemInput withData(String data){
        this.data=data;
        return this;
    }

    private boolean isGoneInput = false;
    public ItemInput withTvShow(boolean goneInput){
        (view.findViewById(R.id.tv)).setVisibility(View.VISIBLE);
        this.isGoneInput = goneInput;
        return this;
    }

    private LoginInputEdit input;
    public LoginInputEdit getInput(){
        return input;
    }

    public TextView getTv(){
        return ((TextView)view.findViewById(R.id.tv));
    }

    public ItemInput init(){
        if(title!=null){
            ((TextView)view.findViewById(R.id.text)).setText(title);
            ((LoginInputEdit)view.findViewById(R.id.input)).setTextStr(data);//hhc

        }

        if(isGoneInput){
            view.findViewById(R.id.input).setVisibility(View.GONE);
        }else{
            input = (LoginInputEdit) view.findViewById(R.id.input);

        }
        return this;
    }

}
